package com.scaffold.catalog.entity;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.SequenceGenerator;

import org.hibernate.annotations.Cache;
import org.hibernate.annotations.CacheConcurrencyStrategy;

import com.scaffold.springmvc.entity.BasicEntity;


/**
 * 分类
 * @author wangjg
 *
 */
@Entity
@Cache(usage = CacheConcurrencyStrategy.NONSTRICT_READ_WRITE)
public class Catalog extends BasicEntity {
	private static final long serialVersionUID = 1L;
	
	@Id
	@GeneratedValue(strategy = GenerationType.SEQUENCE, generator = "g")
	@SequenceGenerator(name = "g", sequenceName = "SEQ_CATALOG",allocationSize=1)
	private Long id; //id
	
	// 名称
	@Column(length=50, nullable=false)
	private String name;
	
	// 父ID @ref Catalog#id
	@Column(nullable=false)
	private Long parentId;
	
	public Long getId() {
		return id;
	}
	public void setId(Long id) {
		this.id = id;
	}
	public String getName() {
		return name;
	}
	public void setName(String name) {
		this.name = name;
	}
	public Long getParentId() {
		return parentId;
	}
	public void setParentId(Long parentId) {
		this.parentId = parentId;
	}
	@Override
	public String toString() {
		return "Catalog [id=" + id + ", name=" + name + ", parentId="
				+ parentId + "]";
	}
	
}
